<html>
  <head>
  <title>crawler.py</title>
  </head>
  <body>
  <h3>crawler.py (<a href="../crawler.py">original</a>)</h3>
  <hr>
  <pre>
<span style="color: green; font-style: italic"># crawler.py
# ----------
# Licensing Information: Please do not distribute or publish solutions to this
# project. You are free to use and extend these projects for educational
# purposes. The Pacman AI projects were developed at UC Berkeley, primarily by
# John DeNero (denero@cs.berkeley.edu) and Dan Klein (klein@cs.berkeley.edu).
# For more info, see http://inst.eecs.berkeley.edu/~cs188/sp09/pacman.html

#!/usr/bin/python
</span><span style="color: blue; font-weight: bold">import </span>math
<span style="color: blue; font-weight: bold">from </span>math <span style="color: blue; font-weight: bold">import </span>pi as PI
<span style="color: blue; font-weight: bold">import </span>time
<span style="color: blue; font-weight: bold">import </span>environment
<span style="color: blue; font-weight: bold">import </span>random

<span style="color: blue; font-weight: bold">class </span>CrawlingRobotEnvironment<span style="font-weight: bold">(</span>environment<span style="font-weight: bold">.</span>Environment<span style="font-weight: bold">):

   </span><span style="color: blue; font-weight: bold">def </span>__init__<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">, </span>crawlingRobot<span style="font-weight: bold">):

       </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>crawlingRobot <span style="font-weight: bold">= </span>crawlingRobot

       <span style="color: green; font-style: italic"># The state is of the form (armAngle, handAngle)
       # where the angles are bucket numbers, not actual
       # degree measurements
       </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>state <span style="font-weight: bold">= </span><span style="color: blue">None

       self</span><span style="font-weight: bold">.</span>nArmStates <span style="font-weight: bold">= </span><span style="color: red">9
       </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>nHandStates <span style="font-weight: bold">= </span><span style="color: red">13

       </span><span style="color: green; font-style: italic"># create a list of arm buckets and hand buckets to
       # discretize the state space
       </span>minArmAngle<span style="font-weight: bold">,</span>maxArmAngle <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>crawlingRobot<span style="font-weight: bold">.</span>getMinAndMaxArmAngles<span style="font-weight: bold">()
       </span>minHandAngle<span style="font-weight: bold">,</span>maxHandAngle <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>crawlingRobot<span style="font-weight: bold">.</span>getMinAndMaxHandAngles<span style="font-weight: bold">()
       </span>armIncrement <span style="font-weight: bold">= (</span>maxArmAngle <span style="font-weight: bold">- </span>minArmAngle<span style="font-weight: bold">) / (</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>nArmStates<span style="font-weight: bold">-</span><span style="color: red">1</span><span style="font-weight: bold">)
       </span>handIncrement <span style="font-weight: bold">= (</span>maxHandAngle <span style="font-weight: bold">- </span>minHandAngle<span style="font-weight: bold">) / (</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>nHandStates<span style="font-weight: bold">-</span><span style="color: red">1</span><span style="font-weight: bold">)
       </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armBuckets <span style="font-weight: bold">= [</span>minArmAngle<span style="font-weight: bold">+(</span>armIncrement<span style="font-weight: bold">*</span>i<span style="font-weight: bold">) </span>\
          <span style="color: blue; font-weight: bold">for </span>i <span style="color: blue; font-weight: bold">in </span>range<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>nArmStates<span style="font-weight: bold">)]
       </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handBuckets <span style="font-weight: bold">= [</span>minHandAngle<span style="font-weight: bold">+(</span>handIncrement<span style="font-weight: bold">*</span>i<span style="font-weight: bold">) </span>\
        <span style="color: blue; font-weight: bold">for </span>i <span style="color: blue; font-weight: bold">in </span>range<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>nHandStates<span style="font-weight: bold">)]

       </span><span style="color: green; font-style: italic"># Reset
       </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>reset<span style="font-weight: bold">()

   </span><span style="color: blue; font-weight: bold">def </span>getCurrentState<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">):
       </span><span style="color: darkred">"""
         Return the current state
         of the crawling robot
       """
       </span><span style="color: blue; font-weight: bold">return </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>state

   <span style="color: blue; font-weight: bold">def </span>getPossibleActions<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">, </span>state<span style="font-weight: bold">):
       </span><span style="color: darkred">"""
         Returns possible actions
         for the states in the
         current state
       """

       </span>actions <span style="font-weight: bold">= </span>list<span style="font-weight: bold">()

       </span>currArmBucket<span style="font-weight: bold">,</span>currHandBucket <span style="font-weight: bold">= </span>state
       <span style="color: blue; font-weight: bold">if </span>currArmBucket <span style="font-weight: bold">&gt; </span><span style="color: red">0</span><span style="font-weight: bold">: </span>actions<span style="font-weight: bold">.</span>append<span style="font-weight: bold">(</span><span style="color: red">'arm-down'</span><span style="font-weight: bold">)
       </span><span style="color: blue; font-weight: bold">if </span>currArmBucket <span style="font-weight: bold">&lt; </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>nArmStates<span style="font-weight: bold">-</span><span style="color: red">1</span><span style="font-weight: bold">: </span>actions<span style="font-weight: bold">.</span>append<span style="font-weight: bold">(</span><span style="color: red">'arm-up'</span><span style="font-weight: bold">)
       </span><span style="color: blue; font-weight: bold">if </span>currHandBucket <span style="font-weight: bold">&gt; </span><span style="color: red">0</span><span style="font-weight: bold">: </span>actions<span style="font-weight: bold">.</span>append<span style="font-weight: bold">(</span><span style="color: red">'hand-down'</span><span style="font-weight: bold">)
       </span><span style="color: blue; font-weight: bold">if </span>currHandBucket <span style="font-weight: bold">&lt; </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>nHandStates<span style="font-weight: bold">-</span><span style="color: red">1</span><span style="font-weight: bold">: </span>actions<span style="font-weight: bold">.</span>append<span style="font-weight: bold">(</span><span style="color: red">'hand-up'</span><span style="font-weight: bold">)

       </span><span style="color: blue; font-weight: bold">return </span>actions

   <span style="color: blue; font-weight: bold">def </span>doAction<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">, </span>action<span style="font-weight: bold">):
       </span><span style="color: darkred">"""
         Perform the action and update
         the current state of the Environment
         and return the reward for the
         current state, the next state
         and the taken action.

         Returns:
           nextState, reward
       """
       </span>nextState<span style="font-weight: bold">, </span>reward <span style="font-weight: bold">=  </span><span style="color: blue">None</span><span style="font-weight: bold">, </span><span style="color: blue">None

       </span>oldX<span style="font-weight: bold">,</span>oldY <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>crawlingRobot<span style="font-weight: bold">.</span>getRobotPosition<span style="font-weight: bold">()

       </span>armBucket<span style="font-weight: bold">,</span>handBucket <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>state
       armAngle<span style="font-weight: bold">,</span>handAngle <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>crawlingRobot<span style="font-weight: bold">.</span>getAngles<span style="font-weight: bold">()
       </span><span style="color: blue; font-weight: bold">if </span>action <span style="font-weight: bold">== </span><span style="color: red">'arm-up'</span><span style="font-weight: bold">:
         </span>newArmAngle <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armBuckets<span style="font-weight: bold">[</span>armBucket<span style="font-weight: bold">+</span><span style="color: red">1</span><span style="font-weight: bold">]
         </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>crawlingRobot<span style="font-weight: bold">.</span>moveArm<span style="font-weight: bold">(</span>newArmAngle<span style="font-weight: bold">)
         </span>nextState <span style="font-weight: bold">= (</span>armBucket<span style="font-weight: bold">+</span><span style="color: red">1</span><span style="font-weight: bold">,</span>handBucket<span style="font-weight: bold">)
       </span><span style="color: blue; font-weight: bold">if </span>action <span style="font-weight: bold">== </span><span style="color: red">'arm-down'</span><span style="font-weight: bold">:
         </span>newArmAngle <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armBuckets<span style="font-weight: bold">[</span>armBucket<span style="font-weight: bold">-</span><span style="color: red">1</span><span style="font-weight: bold">]
         </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>crawlingRobot<span style="font-weight: bold">.</span>moveArm<span style="font-weight: bold">(</span>newArmAngle<span style="font-weight: bold">)
         </span>nextState <span style="font-weight: bold">= (</span>armBucket<span style="font-weight: bold">-</span><span style="color: red">1</span><span style="font-weight: bold">,</span>handBucket<span style="font-weight: bold">)
       </span><span style="color: blue; font-weight: bold">if </span>action <span style="font-weight: bold">== </span><span style="color: red">'hand-up'</span><span style="font-weight: bold">:
         </span>newHandAngle <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handBuckets<span style="font-weight: bold">[</span>handBucket<span style="font-weight: bold">+</span><span style="color: red">1</span><span style="font-weight: bold">]
         </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>crawlingRobot<span style="font-weight: bold">.</span>moveHand<span style="font-weight: bold">(</span>newHandAngle<span style="font-weight: bold">)
         </span>nextState <span style="font-weight: bold">= (</span>armBucket<span style="font-weight: bold">,</span>handBucket<span style="font-weight: bold">+</span><span style="color: red">1</span><span style="font-weight: bold">)
       </span><span style="color: blue; font-weight: bold">if </span>action <span style="font-weight: bold">== </span><span style="color: red">'hand-down'</span><span style="font-weight: bold">:
         </span>newHandAngle <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handBuckets<span style="font-weight: bold">[</span>handBucket<span style="font-weight: bold">-</span><span style="color: red">1</span><span style="font-weight: bold">]
         </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>crawlingRobot<span style="font-weight: bold">.</span>moveHand<span style="font-weight: bold">(</span>newHandAngle<span style="font-weight: bold">)
         </span>nextState <span style="font-weight: bold">= (</span>armBucket<span style="font-weight: bold">,</span>handBucket<span style="font-weight: bold">-</span><span style="color: red">1</span><span style="font-weight: bold">)
         
       </span>newX<span style="font-weight: bold">,</span>newY <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>crawlingRobot<span style="font-weight: bold">.</span>getRobotPosition<span style="font-weight: bold">()
       
       </span><span style="color: green; font-style: italic"># a simple reward function
       </span>reward <span style="font-weight: bold">= </span>newX <span style="font-weight: bold">- </span>oldX
       
       <span style="color: blue">self</span><span style="font-weight: bold">.</span>state <span style="font-weight: bold">= </span>nextState
       <span style="color: blue; font-weight: bold">return </span>nextState<span style="font-weight: bold">, </span>reward


   <span style="color: blue; font-weight: bold">def </span>reset<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">):
       </span><span style="color: darkred">"""
        Resets the Environment to the initial state
       """
       </span><span style="color: green; font-style: italic">## Initialize the state to be the middle
       ## value for each parameter e.g. if there are 13 and 19
       ## buckets for the arm and hand parameters, then the intial
       ## state should be (6,9)
       ##
       ## Also call self.crawlingRobot.setAngles()
       ## to the initial arm and hand angle

       </span>armState <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>nArmStates<span style="font-weight: bold">/</span><span style="color: red">2
       </span>handState <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>nHandStates<span style="font-weight: bold">/</span><span style="color: red">2
       </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>state <span style="font-weight: bold">= </span>armState<span style="font-weight: bold">,</span>handState
       <span style="color: blue">self</span><span style="font-weight: bold">.</span>crawlingRobot<span style="font-weight: bold">.</span>setAngles<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armBuckets<span style="font-weight: bold">[</span>armState<span style="font-weight: bold">],</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handBuckets<span style="font-weight: bold">[</span>handState<span style="font-weight: bold">])
       </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>crawlingRobot<span style="font-weight: bold">.</span>positions <span style="font-weight: bold">= [</span><span style="color: red">20</span><span style="font-weight: bold">,</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>crawlingRobot<span style="font-weight: bold">.</span>getRobotPosition<span style="font-weight: bold">()[</span><span style="color: red">0</span><span style="font-weight: bold">]]


</span><span style="color: blue; font-weight: bold">class </span>CrawlingRobot<span style="font-weight: bold">:
    
    </span><span style="color: blue; font-weight: bold">def </span>setAngles<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">, </span>armAngle<span style="font-weight: bold">, </span>handAngle<span style="font-weight: bold">):
        </span><span style="color: darkred">"""
            set the robot's arm and hand angles
            to the passed in values
        """
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armAngle <span style="font-weight: bold">= </span>armAngle
        <span style="color: blue">self</span><span style="font-weight: bold">.</span>handAngle <span style="font-weight: bold">= </span>handAngle
        
    <span style="color: blue; font-weight: bold">def </span>getAngles<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">):
        </span><span style="color: darkred">"""
            returns the pair of (armAngle, handAngle)
        """
        </span><span style="color: blue; font-weight: bold">return </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armAngle<span style="font-weight: bold">, </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handAngle
            
    <span style="color: blue; font-weight: bold">def </span>getRobotPosition<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">):
        </span><span style="color: darkred">"""
            returns the (x,y) coordinates
            of the lower-left point of the
            robot
        """
        </span><span style="color: blue; font-weight: bold">return </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotPos
    
    <span style="color: blue; font-weight: bold">def </span>moveArm<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">, </span>newArmAngle<span style="font-weight: bold">):
        </span><span style="color: darkred">"""
            move the robot arm to 'newArmAngle'
        """
        </span>oldArmAngle <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armAngle
        <span style="color: blue; font-weight: bold">if </span>newArmAngle <span style="font-weight: bold">&gt; </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>maxArmAngle<span style="font-weight: bold">:
            </span><span style="color: blue; font-weight: bold">raise </span><span style="color: red">'Crawling Robot: Arm Raised too high. Careful!'
        </span><span style="color: blue; font-weight: bold">if </span>newArmAngle <span style="font-weight: bold">&lt; </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>minArmAngle<span style="font-weight: bold">:
            </span><span style="color: blue; font-weight: bold">raise </span><span style="color: red">'Crawling Robot: Arm Raised too low. Careful!'
        </span>disp <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>displacement<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armAngle<span style="font-weight: bold">, </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handAngle<span style="font-weight: bold">, 
                                  </span>newArmAngle<span style="font-weight: bold">, </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handAngle<span style="font-weight: bold">)
        </span>curXPos <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotPos<span style="font-weight: bold">[</span><span style="color: red">0</span><span style="font-weight: bold">]
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotPos <span style="font-weight: bold">= (</span>curXPos<span style="font-weight: bold">+</span>disp<span style="font-weight: bold">, </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotPos<span style="font-weight: bold">[</span><span style="color: red">1</span><span style="font-weight: bold">])
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armAngle <span style="font-weight: bold">= </span>newArmAngle
        
        <span style="color: green; font-style: italic"># Position and Velocity Sign Post
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>positions<span style="font-weight: bold">.</span>append<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>getRobotPosition<span style="font-weight: bold">()[</span><span style="color: red">0</span><span style="font-weight: bold">])
</span><span style="color: green; font-style: italic">#        self.angleSums.append(abs(math.degrees(oldArmAngle)-math.degrees(newArmAngle)))
        </span><span style="color: blue; font-weight: bold">if </span>len<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>positions<span style="font-weight: bold">) &gt; </span><span style="color: red">100</span><span style="font-weight: bold">:
            </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>positions<span style="font-weight: bold">.</span>pop<span style="font-weight: bold">(</span><span style="color: red">0</span><span style="font-weight: bold">)
 </span><span style="color: green; font-style: italic">#           self.angleSums.pop(0)
        
    </span><span style="color: blue; font-weight: bold">def </span>moveHand<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">, </span>newHandAngle<span style="font-weight: bold">):
        </span><span style="color: darkred">"""
            move the robot hand to 'newArmAngle' 
        """
        </span>oldHandAngle <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handAngle
        
        <span style="color: blue; font-weight: bold">if </span>newHandAngle <span style="font-weight: bold">&gt; </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>maxHandAngle<span style="font-weight: bold">:
            </span><span style="color: blue; font-weight: bold">raise </span><span style="color: red">'Crawling Robot: Hand Raised too high. Careful!'
        </span><span style="color: blue; font-weight: bold">if </span>newHandAngle <span style="font-weight: bold">&lt; </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>minHandAngle<span style="font-weight: bold">:
            </span><span style="color: blue; font-weight: bold">raise </span><span style="color: red">'Crawling Robot: Hand Raised too low. Careful!'
        </span>disp <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>displacement<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armAngle<span style="font-weight: bold">, </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handAngle<span style="font-weight: bold">, </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armAngle<span style="font-weight: bold">, </span>newHandAngle<span style="font-weight: bold">)
        </span>curXPos <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotPos<span style="font-weight: bold">[</span><span style="color: red">0</span><span style="font-weight: bold">]
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotPos <span style="font-weight: bold">= (</span>curXPos<span style="font-weight: bold">+</span>disp<span style="font-weight: bold">, </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotPos<span style="font-weight: bold">[</span><span style="color: red">1</span><span style="font-weight: bold">])
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handAngle <span style="font-weight: bold">= </span>newHandAngle
        
        <span style="color: green; font-style: italic"># Position and Velocity Sign Post
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>positions<span style="font-weight: bold">.</span>append<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>getRobotPosition<span style="font-weight: bold">()[</span><span style="color: red">0</span><span style="font-weight: bold">])
 </span><span style="color: green; font-style: italic">#       self.angleSums.append(abs(math.degrees(oldHandAngle)-math.degrees(newHandAngle)))
        </span><span style="color: blue; font-weight: bold">if </span>len<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>positions<span style="font-weight: bold">) &gt; </span><span style="color: red">100</span><span style="font-weight: bold">:
            </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>positions<span style="font-weight: bold">.</span>pop<span style="font-weight: bold">(</span><span style="color: red">0</span><span style="font-weight: bold">)
 </span><span style="color: green; font-style: italic">#           self.angleSums.pop(0)

    </span><span style="color: blue; font-weight: bold">def </span>getMinAndMaxArmAngles<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">):
        </span><span style="color: darkred">"""
            get the lower- and upper- bound
            for the arm angles returns (min,max) pair
        """
        </span><span style="color: blue; font-weight: bold">return </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>minArmAngle<span style="font-weight: bold">, </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>maxArmAngle

    <span style="color: blue; font-weight: bold">def </span>getMinAndMaxHandAngles<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">):
        </span><span style="color: darkred">"""
            get the lower- and upper- bound
            for the hand angles returns (min,max) pair
        """        
        </span><span style="color: blue; font-weight: bold">return </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>minHandAngle<span style="font-weight: bold">, </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>maxHandAngle
    
    <span style="color: blue; font-weight: bold">def </span>getRotationAngle<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">):
        </span><span style="color: darkred">"""
            get the current angle the 
            robot body is rotated off the ground
        """
        </span>armCos<span style="font-weight: bold">, </span>armSin <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>__getCosAndSin<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armAngle<span style="font-weight: bold">)
        </span>handCos<span style="font-weight: bold">, </span>handSin <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>__getCosAndSin<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handAngle<span style="font-weight: bold">)
        </span>x <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armLength <span style="font-weight: bold">* </span>armCos <span style="font-weight: bold">+ </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handLength <span style="font-weight: bold">* </span>handCos <span style="font-weight: bold">+ </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotWidth
        y <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armLength <span style="font-weight: bold">* </span>armSin <span style="font-weight: bold">+ </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handLength <span style="font-weight: bold">* </span>handSin <span style="font-weight: bold">+ </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotHeight
        <span style="color: blue; font-weight: bold">if </span>y <span style="font-weight: bold">&lt; </span><span style="color: red">0</span><span style="font-weight: bold">:
            </span><span style="color: blue; font-weight: bold">return </span>math<span style="font-weight: bold">.</span>atan<span style="font-weight: bold">(-</span>y<span style="font-weight: bold">/</span>x<span style="font-weight: bold">)
        </span><span style="color: blue; font-weight: bold">return </span><span style="color: red">0.0


    </span><span style="color: green; font-style: italic">## You shouldn't need methods below here

        
    </span><span style="color: blue; font-weight: bold">def </span>__getCosAndSin<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">, </span>angle<span style="font-weight: bold">):
        </span><span style="color: blue; font-weight: bold">return </span>math<span style="font-weight: bold">.</span>cos<span style="font-weight: bold">(</span>angle<span style="font-weight: bold">), </span>math<span style="font-weight: bold">.</span>sin<span style="font-weight: bold">(</span>angle<span style="font-weight: bold">)
                 
    </span><span style="color: blue; font-weight: bold">def </span>displacement<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">, </span>oldArmDegree<span style="font-weight: bold">, </span>oldHandDegree<span style="font-weight: bold">, </span>armDegree<span style="font-weight: bold">, </span>handDegree<span style="font-weight: bold">):

        </span>oldArmCos<span style="font-weight: bold">, </span>oldArmSin <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>__getCosAndSin<span style="font-weight: bold">(</span>oldArmDegree<span style="font-weight: bold">)
        </span>armCos<span style="font-weight: bold">, </span>armSin <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>__getCosAndSin<span style="font-weight: bold">(</span>armDegree<span style="font-weight: bold">)
        </span>oldHandCos<span style="font-weight: bold">, </span>oldHandSin <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>__getCosAndSin<span style="font-weight: bold">(</span>oldHandDegree<span style="font-weight: bold">)
        </span>handCos<span style="font-weight: bold">, </span>handSin <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>__getCosAndSin<span style="font-weight: bold">(</span>handDegree<span style="font-weight: bold">)

        </span>xOld <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armLength <span style="font-weight: bold">* </span>oldArmCos <span style="font-weight: bold">+ </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handLength <span style="font-weight: bold">* </span>oldHandCos <span style="font-weight: bold">+ </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotWidth
        yOld <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armLength <span style="font-weight: bold">* </span>oldArmSin <span style="font-weight: bold">+ </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handLength <span style="font-weight: bold">* </span>oldHandSin <span style="font-weight: bold">+ </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotHeight

        x <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armLength <span style="font-weight: bold">* </span>armCos <span style="font-weight: bold">+ </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handLength <span style="font-weight: bold">* </span>handCos <span style="font-weight: bold">+ </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotWidth
        y <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armLength <span style="font-weight: bold">* </span>armSin <span style="font-weight: bold">+ </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handLength <span style="font-weight: bold">* </span>handSin <span style="font-weight: bold">+ </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotHeight

        <span style="color: blue; font-weight: bold">if </span>y <span style="font-weight: bold">&lt; </span><span style="color: red">0</span><span style="font-weight: bold">:
            </span><span style="color: blue; font-weight: bold">if </span>yOld <span style="font-weight: bold">&lt;= </span><span style="color: red">0</span><span style="font-weight: bold">:
                </span><span style="color: blue; font-weight: bold">return </span>math<span style="font-weight: bold">.</span>sqrt<span style="font-weight: bold">(</span>xOld<span style="font-weight: bold">*</span>xOld <span style="font-weight: bold">+ </span>yOld<span style="font-weight: bold">*</span>yOld<span style="font-weight: bold">) - </span>math<span style="font-weight: bold">.</span>sqrt<span style="font-weight: bold">(</span>x<span style="font-weight: bold">*</span>x <span style="font-weight: bold">+ </span>y<span style="font-weight: bold">*</span>y<span style="font-weight: bold">)
            </span><span style="color: blue; font-weight: bold">return </span><span style="font-weight: bold">(</span>xOld <span style="font-weight: bold">- </span>yOld<span style="font-weight: bold">*(</span>x<span style="font-weight: bold">-</span>xOld<span style="font-weight: bold">) / (</span>y <span style="font-weight: bold">- </span>yOld<span style="font-weight: bold">)) - </span>math<span style="font-weight: bold">.</span>sqrt<span style="font-weight: bold">(</span>x<span style="font-weight: bold">*</span>x <span style="font-weight: bold">+ </span>y<span style="font-weight: bold">*</span>y<span style="font-weight: bold">)
        </span><span style="color: blue; font-weight: bold">else</span><span style="font-weight: bold">:
            </span><span style="color: blue; font-weight: bold">if </span>yOld  <span style="font-weight: bold">&gt;= </span><span style="color: red">0</span><span style="font-weight: bold">:
                </span><span style="color: blue; font-weight: bold">return </span><span style="color: red">0.0
            </span><span style="color: blue; font-weight: bold">return </span><span style="font-weight: bold">-(</span>x <span style="font-weight: bold">- </span>y <span style="font-weight: bold">* (</span>xOld<span style="font-weight: bold">-</span>x<span style="font-weight: bold">)/(</span>yOld<span style="font-weight: bold">-</span>y<span style="font-weight: bold">)) + </span>math<span style="font-weight: bold">.</span>sqrt<span style="font-weight: bold">(</span>xOld<span style="font-weight: bold">*</span>xOld <span style="font-weight: bold">+ </span>yOld<span style="font-weight: bold">*</span>yOld<span style="font-weight: bold">)

        </span><span style="color: blue; font-weight: bold">raise </span><span style="color: red">'Never Should See This!'
    
    </span><span style="color: blue; font-weight: bold">def </span>draw<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">, </span>stepCount<span style="font-weight: bold">, </span>stepDelay<span style="font-weight: bold">):
        </span>x1<span style="font-weight: bold">, </span>y1 <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>getRobotPosition<span style="font-weight: bold">()
        </span>x1 <span style="font-weight: bold">= </span>x1 <span style="font-weight: bold">% </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>totWidth

        <span style="color: green; font-style: italic">## Check Lower Still on the ground
        </span><span style="color: blue; font-weight: bold">if </span>y1 <span style="font-weight: bold">!= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>groundY<span style="font-weight: bold">:
            </span><span style="color: blue; font-weight: bold">raise </span><span style="color: red">'Flying Robot!!'

        </span>rotationAngle <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>getRotationAngle<span style="font-weight: bold">()
        </span>cosRot<span style="font-weight: bold">, </span>sinRot <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>__getCosAndSin<span style="font-weight: bold">(</span>rotationAngle<span style="font-weight: bold">)

        </span>x2 <span style="font-weight: bold">= </span>x1 <span style="font-weight: bold">+ </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotWidth <span style="font-weight: bold">* </span>cosRot
        y2 <span style="font-weight: bold">= </span>y1 <span style="font-weight: bold">- </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotWidth <span style="font-weight: bold">* </span>sinRot

        x3 <span style="font-weight: bold">= </span>x1 <span style="font-weight: bold">- </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotHeight <span style="font-weight: bold">* </span>sinRot
        y3 <span style="font-weight: bold">= </span>y1 <span style="font-weight: bold">- </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotHeight <span style="font-weight: bold">* </span>cosRot

        x4 <span style="font-weight: bold">= </span>x3 <span style="font-weight: bold">+ </span>cosRot<span style="font-weight: bold">*</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotWidth
        y4 <span style="font-weight: bold">= </span>y3 <span style="font-weight: bold">- </span>sinRot<span style="font-weight: bold">*</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotWidth
        
        <span style="color: blue">self</span><span style="font-weight: bold">.</span>canvas<span style="font-weight: bold">.</span>coords<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotBody<span style="font-weight: bold">,</span>x1<span style="font-weight: bold">,</span>y1<span style="font-weight: bold">,</span>x2<span style="font-weight: bold">,</span>y2<span style="font-weight: bold">,</span>x4<span style="font-weight: bold">,</span>y4<span style="font-weight: bold">,</span>x3<span style="font-weight: bold">,</span>y3<span style="font-weight: bold">)

        </span>armCos<span style="font-weight: bold">, </span>armSin <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>__getCosAndSin<span style="font-weight: bold">(</span>rotationAngle<span style="font-weight: bold">+</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armAngle<span style="font-weight: bold">)
        </span>xArm <span style="font-weight: bold">= </span>x4 <span style="font-weight: bold">+ </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armLength <span style="font-weight: bold">* </span>armCos
        yArm <span style="font-weight: bold">= </span>y4 <span style="font-weight: bold">- </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armLength <span style="font-weight: bold">* </span>armSin

        <span style="color: blue">self</span><span style="font-weight: bold">.</span>canvas<span style="font-weight: bold">.</span>coords<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotArm<span style="font-weight: bold">,</span>x4<span style="font-weight: bold">,</span>y4<span style="font-weight: bold">,</span>xArm<span style="font-weight: bold">,</span>yArm<span style="font-weight: bold">)

        </span>handCos<span style="font-weight: bold">, </span>handSin <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>__getCosAndSin<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handAngle<span style="font-weight: bold">+</span>rotationAngle<span style="font-weight: bold">)
        </span>xHand <span style="font-weight: bold">= </span>xArm <span style="font-weight: bold">+ </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handLength <span style="font-weight: bold">* </span>handCos
        yHand <span style="font-weight: bold">= </span>yArm <span style="font-weight: bold">- </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handLength <span style="font-weight: bold">* </span>handSin

        <span style="color: blue">self</span><span style="font-weight: bold">.</span>canvas<span style="font-weight: bold">.</span>coords<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotHand<span style="font-weight: bold">,</span>xArm<span style="font-weight: bold">,</span>yArm<span style="font-weight: bold">,</span>xHand<span style="font-weight: bold">,</span>yHand<span style="font-weight: bold">)
    

        </span><span style="color: green; font-style: italic"># Position and Velocity Sign Post
#        time = len(self.positions) + 0.5 * sum(self.angleSums)
#        velocity = (self.positions[-1]-self.positions[0]) / time
#        if len(self.positions) == 1: return
        </span>steps <span style="font-weight: bold">= (</span>stepCount <span style="font-weight: bold">- </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>lastStep<span style="font-weight: bold">)
        </span><span style="color: blue; font-weight: bold">if </span>steps<span style="font-weight: bold">==</span><span style="color: red">0</span><span style="font-weight: bold">:</span><span style="color: blue; font-weight: bold">return
 </span><span style="color: green; font-style: italic">#       pos = self.positions[-1]
#        velocity = (pos - self.lastPos) / steps 
  #      g = .9 ** (10 * stepDelay)
#        g = .99 ** steps
#        self.velAvg = g * self.velAvg + (1 - g) * velocity 
 #       g = .999 ** steps
 #       self.velAvg2 = g * self.velAvg2 + (1 - g) * velocity 
        </span>pos <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>positions<span style="font-weight: bold">[-</span><span style="color: red">1</span><span style="font-weight: bold">]
        </span>velocity <span style="font-weight: bold">= </span>pos <span style="font-weight: bold">- </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>positions<span style="font-weight: bold">[-</span><span style="color: red">2</span><span style="font-weight: bold">]
        </span>vel2 <span style="font-weight: bold">= (</span>pos <span style="font-weight: bold">- </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>positions<span style="font-weight: bold">[</span><span style="color: red">0</span><span style="font-weight: bold">]) / </span>len<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>positions<span style="font-weight: bold">)
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>velAvg <span style="font-weight: bold">= .</span><span style="color: red">9 </span><span style="font-weight: bold">* </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>velAvg <span style="font-weight: bold">+ .</span><span style="color: red">1 </span><span style="font-weight: bold">* </span>vel2
        velMsg <span style="font-weight: bold">= </span><span style="color: red">'100-step Avg Velocity: %.2f' </span><span style="font-weight: bold">% </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>velAvg   
<span style="color: green; font-style: italic">#        velMsg2 = '1000-step Avg Velocity: %.2f' % self.velAvg2   
        </span>velocityMsg <span style="font-weight: bold">= </span><span style="color: red">'Velocity: %.2f' </span><span style="font-weight: bold">% </span>velocity   
        positionMsg <span style="font-weight: bold">= </span><span style="color: red">'Position: %2.f' </span><span style="font-weight: bold">% </span>pos
        stepMsg <span style="font-weight: bold">= </span><span style="color: red">'Step: %d' </span><span style="font-weight: bold">% </span>stepCount
        <span style="color: blue; font-weight: bold">if </span><span style="color: red">'vel_msg' </span><span style="color: blue; font-weight: bold">in </span>dir<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">):
            </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>canvas<span style="font-weight: bold">.</span>delete<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>vel_msg<span style="font-weight: bold">)
            </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>canvas<span style="font-weight: bold">.</span>delete<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>pos_msg<span style="font-weight: bold">)
            </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>canvas<span style="font-weight: bold">.</span>delete<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>step_msg<span style="font-weight: bold">)
            </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>canvas<span style="font-weight: bold">.</span>delete<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>velavg_msg<span style="font-weight: bold">)
 </span><span style="color: green; font-style: italic">#           self.canvas.delete(self.velavg2_msg)
 #       self.velavg2_msg = self.canvas.create_text(850,190,text=velMsg2) 
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>velavg_msg <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>canvas<span style="font-weight: bold">.</span>create_text<span style="font-weight: bold">(</span><span style="color: red">650</span><span style="font-weight: bold">,</span><span style="color: red">190</span><span style="font-weight: bold">,</span>text<span style="font-weight: bold">=</span>velMsg<span style="font-weight: bold">) 
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>vel_msg <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>canvas<span style="font-weight: bold">.</span>create_text<span style="font-weight: bold">(</span><span style="color: red">450</span><span style="font-weight: bold">,</span><span style="color: red">190</span><span style="font-weight: bold">,</span>text<span style="font-weight: bold">=</span>velocityMsg<span style="font-weight: bold">) 
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>pos_msg <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>canvas<span style="font-weight: bold">.</span>create_text<span style="font-weight: bold">(</span><span style="color: red">250</span><span style="font-weight: bold">,</span><span style="color: red">190</span><span style="font-weight: bold">,</span>text<span style="font-weight: bold">=</span>positionMsg<span style="font-weight: bold">)
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>step_msg <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>canvas<span style="font-weight: bold">.</span>create_text<span style="font-weight: bold">(</span><span style="color: red">50</span><span style="font-weight: bold">,</span><span style="color: red">190</span><span style="font-weight: bold">,</span>text<span style="font-weight: bold">=</span>stepMsg<span style="font-weight: bold">)
</span><span style="color: green; font-style: italic">#        self.lastPos = pos
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>lastStep <span style="font-weight: bold">= </span>stepCount
<span style="color: green; font-style: italic">#        self.lastVel = velocity
    
    </span><span style="color: blue; font-weight: bold">def </span>__init__<span style="font-weight: bold">(</span><span style="color: blue">self</span><span style="font-weight: bold">, </span>canvas<span style="font-weight: bold">):

        </span><span style="color: green; font-style: italic">## Canvas ##
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>canvas <span style="font-weight: bold">= </span>canvas
        <span style="color: blue">self</span><span style="font-weight: bold">.</span>velAvg <span style="font-weight: bold">= </span><span style="color: red">0
</span><span style="color: green; font-style: italic">#        self.velAvg2 = 0
#        self.lastPos = 0
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>lastStep <span style="font-weight: bold">= </span><span style="color: red">0
</span><span style="color: green; font-style: italic">#        self.lastVel = 0

        ## Arm and Hand Degrees ##
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armAngle <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>oldArmDegree <span style="font-weight: bold">= </span><span style="color: red">0.0
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handAngle <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>oldHandDegree <span style="font-weight: bold">= -</span>PI<span style="font-weight: bold">/</span><span style="color: red">6

        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>maxArmAngle <span style="font-weight: bold">= </span>PI<span style="font-weight: bold">/</span><span style="color: red">6
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>minArmAngle <span style="font-weight: bold">= -</span>PI<span style="font-weight: bold">/</span><span style="color: red">6

        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>maxHandAngle <span style="font-weight: bold">= </span><span style="color: red">0
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>minHandAngle <span style="font-weight: bold">= -(</span><span style="color: red">5.0</span><span style="font-weight: bold">/</span><span style="color: red">6.0</span><span style="font-weight: bold">) * </span>PI

        <span style="color: green; font-style: italic">## Draw Ground ##
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>totWidth <span style="font-weight: bold">= </span>canvas<span style="font-weight: bold">.</span>winfo_reqwidth<span style="font-weight: bold">()
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>totHeight <span style="font-weight: bold">= </span>canvas<span style="font-weight: bold">.</span>winfo_reqheight<span style="font-weight: bold">()
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>groundHeight <span style="font-weight: bold">= </span><span style="color: red">40
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>groundY <span style="font-weight: bold">= </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>totHeight <span style="font-weight: bold">- </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>groundHeight
        
        <span style="color: blue">self</span><span style="font-weight: bold">.</span>ground <span style="font-weight: bold">= </span>canvas<span style="font-weight: bold">.</span>create_rectangle<span style="font-weight: bold">(</span><span style="color: red">0</span><span style="font-weight: bold">,
            </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>groundY<span style="font-weight: bold">,</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>totWidth<span style="font-weight: bold">,</span><span style="color: blue">self</span><span style="font-weight: bold">.</span>totHeight<span style="font-weight: bold">, </span>fill<span style="font-weight: bold">=</span><span style="color: red">'blue'</span><span style="font-weight: bold">)

        </span><span style="color: green; font-style: italic">## Robot Body ##
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotWidth <span style="font-weight: bold">= </span><span style="color: red">80
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotHeight <span style="font-weight: bold">= </span><span style="color: red">40
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotPos <span style="font-weight: bold">= (</span><span style="color: red">20</span><span style="font-weight: bold">, </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>groundY<span style="font-weight: bold">)
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotBody <span style="font-weight: bold">= </span>canvas<span style="font-weight: bold">.</span>create_polygon<span style="font-weight: bold">(</span><span style="color: red">0</span><span style="font-weight: bold">,</span><span style="color: red">0</span><span style="font-weight: bold">,</span><span style="color: red">0</span><span style="font-weight: bold">,</span><span style="color: red">0</span><span style="font-weight: bold">,</span><span style="color: red">0</span><span style="font-weight: bold">,</span><span style="color: red">0</span><span style="font-weight: bold">,</span><span style="color: red">0</span><span style="font-weight: bold">,</span><span style="color: red">0</span><span style="font-weight: bold">, </span>fill<span style="font-weight: bold">=</span><span style="color: red">'green'</span><span style="font-weight: bold">)

        </span><span style="color: green; font-style: italic">## Robot Arm ##
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>armLength <span style="font-weight: bold">= </span><span style="color: red">60
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotArm <span style="font-weight: bold">= </span>canvas<span style="font-weight: bold">.</span>create_line<span style="font-weight: bold">(</span><span style="color: red">0</span><span style="font-weight: bold">,</span><span style="color: red">0</span><span style="font-weight: bold">,</span><span style="color: red">0</span><span style="font-weight: bold">,</span><span style="color: red">0</span><span style="font-weight: bold">,</span>fill<span style="font-weight: bold">=</span><span style="color: red">'orange'</span><span style="font-weight: bold">,</span>width<span style="font-weight: bold">=</span><span style="color: red">5</span><span style="font-weight: bold">)

        </span><span style="color: green; font-style: italic">## Robot Hand ##
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>handLength <span style="font-weight: bold">= </span><span style="color: red">40
        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>robotHand <span style="font-weight: bold">= </span>canvas<span style="font-weight: bold">.</span>create_line<span style="font-weight: bold">(</span><span style="color: red">0</span><span style="font-weight: bold">,</span><span style="color: red">0</span><span style="font-weight: bold">,</span><span style="color: red">0</span><span style="font-weight: bold">,</span><span style="color: red">0</span><span style="font-weight: bold">,</span>fill<span style="font-weight: bold">=</span><span style="color: red">'red'</span><span style="font-weight: bold">,</span>width<span style="font-weight: bold">=</span><span style="color: red">3</span><span style="font-weight: bold">)

        </span><span style="color: blue">self</span><span style="font-weight: bold">.</span>positions <span style="font-weight: bold">= [</span><span style="color: red">0</span><span style="font-weight: bold">,</span><span style="color: red">0</span><span style="font-weight: bold">]
  </span><span style="color: green; font-style: italic">#      self.angleSums = [0,0]
 


</span><span style="color: blue; font-weight: bold">if </span>__name__ <span style="font-weight: bold">== </span><span style="color: red">'__main__'</span><span style="font-weight: bold">:      
  </span><span style="color: blue; font-weight: bold">from </span>graphicsCrawlerDisplay <span style="color: blue; font-weight: bold">import </span><span style="font-weight: bold">*
  </span>run<span style="font-weight: bold">()

 </span>
  </pre>
  </body>
  </html>
  